﻿using Puerts;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;

public class JsEnvExample7 : MonoBehaviour
{
    private JsEnv jsEnv;
    // Start is called before the first frame update
    void Start()
    {
        jsEnv = new JsEnv(new DefaultLoader(UnityEngine.Application.dataPath + "/../TsProject/output"), 8282);
        jsEnv.Eval("require('example7/ScriptExample7')");
    }
    public static async Task RotateFroSeconds(GameObject go,float duration)
    {
        var end = Time.time + duration;
        while (Time.time < end)
        {
            go.transform.Rotate(new Vector3(1, 1) * Time.deltaTime * 150);
            await Task.Yield();
        }
    }
    void Update()
    {
        jsEnv.Tick();
    }
    private void OnDestroy()
    {
        jsEnv.Dispose();
    }
}
